package com.tanqing.ddd.web.bean;

import java.io.Serializable;

public class Pageable implements Serializable {
    protected int number;
    protected int size;
    protected int offset;

    public Pageable(int number, int size) {
        this.number = number;
        this.size = size;
        this.offset = (this.number - 1) * this.size;
    }

    public int getOffset() {
        return (this.number - 1) * this.size;
    }

    public int getNumber() {
        return this.number;
    }

    public int getSize() {
        return this.size;
    }

    public void setNumber(final int number) {
        this.number = number;
    }

    public void setSize(final int size) {
        this.size = size;
    }

    public void setOffset(final int offset) {
        this.offset = offset;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Pageable)) {
            return false;
        } else {
            Pageable other = (Pageable)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getNumber() != other.getNumber()) {
                return false;
            } else if (this.getSize() != other.getSize()) {
                return false;
            } else {
                return this.getOffset() == other.getOffset();
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof Pageable;
    }

    public int hashCode() {
        int result = 1;
        result = result * 59 + this.getNumber();
        result = result * 59 + this.getSize();
        result = result * 59 + this.getOffset();
        return result;
    }

    public String toString() {
        return "Pageable(number=" + this.getNumber() + ", size=" + this.getSize() + ", offset=" + this.getOffset() + ")";
    }

    public Pageable() {
    }
}